import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'toFixed'
})
export class ToFixedPipe implements PipeTransform {

  transform(value: number & string, digits: number = 2) {
    if (value === undefined || value === null) return value;
    if (isNaN(parseFloat(value))) return value;
    return parseFloat(value).toFixed(digits);
  }

}